@extends('admin.layout')
@section('title','直播录播管理')
@section('content')
    <div class="app_content_div" id="app_content_div_301Index">
        <h3>直播录播管理</h3>
    </div>
    <div>
        <div style="float:right;">
            <a href="/adm/video/create"> <button type="button" class="btn btn-primary">新增</button></a>
        </div>
    </div>
    <table class="table table-striped">
        <thead>
        <tr>
            <th>id</th>
            <th>标题</th>
            <th>科室</th>
            <th>专家</th>
            <th>类型</th>
            <th>直播开始时间</th>
            <th>直播结束时间</th>
            <th>操作</th>
        </tr>
        </thead>
        @foreach($oVideo as $v)
            <tbody>
            <tr>
                <th>{{$v->id}}</th>
                <th>{{$v->name}}</th>
                <th>@foreach($v->experts as $expert){{$expert->department}}&nbsp;@endforeach</th>
                <th>@foreach($v->experts as $expert){{$expert->name}}&nbsp;|@endforeach</th>
                @if($v->type==1)<th>直播</th>@else()<th>录播</th>@endif
                <th>{{$v->start_at}}</th>
                <th>{{$v->end_at}}</th>
                <th>
                    <a href="/adm/video/{{$v->id}}/edit"><span class="glyphicon glyphicon-edit" aria-hidden="true"></span></a> &nbsp;&nbsp;&nbsp;
                    <a onclick="del({{$v->id}});"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a>
                </th>
            </tr>
            </tbody>
        @endforeach
    </table>
    {{$oVideo->links('admin.page')}}
    <script>

        function del(id){
            var conf = confirm('你确定要删除ID值为'+id+'的记录吗？');
            if(conf==true){
                $.ajax({
                    url:'/adm/video/'+id,
                    type:'DELETE',
                    dataType:'json',
                    data:{'_token':'{{csrf_token()}}'},
                    success:function (data){
                        alert('删除成功');
                        location.href='/adm/video';
                    },
                    error:function (data){}
                });
            }}
    </script>
@endsection
